<template>
  <BasicModal
    v-bind="$attrs"
    destroyOnClose
    @register="register"
    :title="title"
    :showOkBtn="false"
    :showCancelBtn="false"
  >
    <ul v-if="lines.length>0">
      <li v-for="(item, index) in lines" :key="index">{{ item }}</li>
    </ul>
    <template v-else>
      <Empty />
    </template>
  </BasicModal>
</template>
<script lang="ts">
  import { defineComponent, ref, watch } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { Empty } from 'ant-design-vue';

  export default defineComponent({
    components: { BasicModal,Empty},
    setup() {
      const loading = ref(true);
      const lines = ref([]);
      const title = ref('' as any);
      const [register, { redoModalHeight }] = useModalInner(async (data, type) => {
        if (data.type === 1) {
          title.value = '历史记录'
        } else { 
           title.value = '查看备注'
        }
        lines.value = data.data.split('\n');
      });

      watch(
        () => lines.value,
        () => {
          redoModalHeight();
        },
      );

      return { register, loading, lines,title };
    },
  });
</script>
<style scoped>
  .empty-tips {
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
</style>
